
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 05/28/2012 17:31:05
-- Generated from EDMX file: C:\Users\Administrator\documents\visual studio 2010\Projects\Device\Device\Model1.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [VideoEquipment];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[EquipmentMaster集]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EquipmentMaster集];
GO
IF OBJECT_ID(N'[dbo].[Audience集]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Audience集];
GO
IF OBJECT_ID(N'[dbo].[Equiment集]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Equiment集];
GO
IF OBJECT_ID(N'[dbo].[Accesstable集]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Accesstable集];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'EquipmentMaster集'
CREATE TABLE [dbo].[EquipmentMaster集] (
    [id] int IDENTITY(1,1) NOT NULL,
    [username] nvarchar(max)  NOT NULL,
    [password] nvarchar(max)  NOT NULL,
    [email] nvarchar(max)  NOT NULL,
    [question] nvarchar(max)  NULL,
    [answer] nvarchar(max)  NULL,
    [note] nvarchar(max)  NULL,
    [name] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Audience集'
CREATE TABLE [dbo].[Audience集] (
    [id] int IDENTITY(1,1) NOT NULL,
    [username] nvarchar(max)  NULL,
    [password] nvarchar(max)  NOT NULL,
    [email] nvarchar(max)  NOT NULL,
    [question] nvarchar(max)  NULL,
    [answer] nvarchar(max)  NULL,
    [loginpower] nvarchar(max)  NOT NULL,
    [note] nvarchar(max)  NULL,
    [ownerid] int  NOT NULL
);
GO

-- Creating table 'Equiment集'
CREATE TABLE [dbo].[Equiment集] (
    [id] int IDENTITY(1,1) NOT NULL,
    [ownerid] int  NULL,
    [groupname] nvarchar(max)  NULL,
    [audienceid] int  NULL,
    [serialnumber] nvarchar(max)  NOT NULL,
    [EquipmentMaster_id] int  NOT NULL
);
GO

-- Creating table 'Accesstable集'
CREATE TABLE [dbo].[Accesstable集] (
    [audienceid] int  NOT NULL,
    [equimentid] int IDENTITY(1,1) NOT NULL,
    [lookpower] nvarchar(max)  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [id] in table 'EquipmentMaster集'
ALTER TABLE [dbo].[EquipmentMaster集]
ADD CONSTRAINT [PK_EquipmentMaster集]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'Audience集'
ALTER TABLE [dbo].[Audience集]
ADD CONSTRAINT [PK_Audience集]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'Equiment集'
ALTER TABLE [dbo].[Equiment集]
ADD CONSTRAINT [PK_Equiment集]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [equimentid] in table 'Accesstable集'
ALTER TABLE [dbo].[Accesstable集]
ADD CONSTRAINT [PK_Accesstable集]
    PRIMARY KEY CLUSTERED ([equimentid] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------